﻿using Looptribe.Moodlin8.ViewModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Looptribe.Moodlin8.UIHelper
{
    public class CoursesGridView : GridView
    {
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var course = ((CoursesCourseWrapper)item).Course;
            if (course.Id == 1)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, 2);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, 2);
            }
            else if (course.Id > 1 && course.Id < 6)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, 1);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, 2);
            }
            else
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, 1);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, 1);
            }

            base.PrepareContainerForItemOverride(element, item);
        }
    }
}
